package main

import "fmt"

type animal interface {
	move()
	eat(string)
}
type cat struct {
	name string
	feet int8
}

//func (c cat) move() {
//	fmt.Println("走猫步")
//}
//func (c cat) eat(s string) {
//	fmt.Printf("猫吃%s\n", s)
//}

// 使用指针接收者实现接口所有方法
func (c *cat) move() {
	fmt.Println("走猫步")
}
func (c *cat) eat(s string) {
	fmt.Printf("猫吃%s\n", s)
}

func main() {
	var a1 animal
	c1 := cat{"tom", 4}
	c2 := &cat{"孬蛋", 4}
	a1 = &c1
	a1 = c2
	fmt.Println(a1) // &{孬蛋 4}
}
